package com.jerry.basic.thread;
//线程优先级
//不要误以为优先级越高就先执行。谁先执行还是取决于谁先取得CPU的资源
//主线程的优先级是5
public class HelloThreadSetPriority implements Runnable {

	public void run() {
        for(int i=0;i<5;++i){
            System.out.println(Thread.currentThread().getName()+"运行"+i);
        }
    }
 
    public static void main(String[] args) {
        Thread h1=new Thread(new HelloThreadSetPriority(),"A");
        Thread h2=new Thread(new HelloThreadSetPriority(),"B");
        Thread h3=new Thread(new HelloThreadSetPriority(),"C");
        h1.setPriority(8);
        h2.setPriority(2);
        h3.setPriority(6);
        h1.start();
        h2.start();
        h3.start();
         
    }

}
